<template>
  <div>

    <div>
      <el-row :gutter="15">
      <el-form ref="elForm" :model="form" :rules="rules" size="medium" label-width="100px">
        <el-col :span="12">
          <el-form-item label="患者姓名" prop="field101">
            <el-input v-model="form.pName" placeholder="请输入患者姓名" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="患者卡号" prop="field102">
            <el-input v-model="form.pNo" placeholder="请输入患者卡号" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="患者年龄" prop="field105">
            <el-select v-model="form.pAge" placeholder="请选择患者年龄" clearable :style="{width: '100%'}">
              <el-option v-for="(item, index) in field105Options" :key="index" :label="item.label"
                :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="出生日期" prop="field106">
            <el-date-picker v-model="form.pStartDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
              :style="{width: '100%'}" placeholder="请选择出生日期" clearable></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="性别" prop="field104">
            <el-select v-model="form.pSex" placeholder="请选择性别" clearable :style="{width: '100%'}">
              <el-option v-for="(item, index) in field104Options" :key="index" :label="item.label"
                :value="item.value" :disabled="item.disabled"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="手机号码" prop="field103">
            <el-input v-model="form.pPhone" placeholder="请输入手机号码" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="证件号码" prop="mobile">
            <el-input v-model="form.pCard" placeholder="请输入证件号码" :maxlength="11" show-word-limit
              clearable prefix-icon='el-icon-mobile' :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="9">
          <el-form-item label="地址" prop="field110">
            <el-input v-model="form.pProvince" placeholder="请输入地址" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="15">
          <el-form-item label="" prop="field112">
            <el-input v-model="form.pPlace" placeholder="请输入详细地址" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>

        </el-form>
        </el-row>
    </div>


    <div>
      <el-row :gutter="15">
      <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
        <el-col :span="12">
          <el-form-item label="诊断类型" prop="field113">
            <el-input v-model="formData.cType" placeholder="请输入诊断类型" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="诊断" prop="field113">
            <el-input v-model="formData.cDiagnose" placeholder="请输入诊断" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="医嘱" prop="field114">
            <el-input v-model="formData.cAdvice" placeholder="请输入医嘱" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
      <el-col :span="6">
          <el-form-item label="体温" prop="field115">
            <el-input v-model="formData.cTemperature" clearable :style="{width: '100%'}">
              <template slot="append">°C</template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="呼吸" prop="field116">
            <el-input v-model="formData.cBreathe" clearable :style="{width: '100%'}">
              <template slot="append">次/分 </template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label=" 脉搏" prop="field117">
            <el-input v-model="formData.cPulse" clearable :style="{width: '100%'}">
              <template slot="append">次/分</template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="血压" prop="field118">
            <el-input v-model="formData.cBloodPressure" placeholder="高压/低压" clearable :style="{width: '100%'}">
              <template slot="append">mmhg</template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="身高" prop="field119">
            <el-input v-model="formData.cHeight" placeholder="请输入身高" clearable :style="{width: '100%'}">
              <template slot="append">°C</template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="体重" prop="field120">
            <el-input v-model="formData.cWeight" placeholder="请输入体重" clearable :style="{width: '100%'}">
              <template slot="append">Kg</template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="血糖" prop="field121">
            <el-input v-model="formData.cBloodSugar" placeholder="请输入血糖" clearable :style="{width: '100%'}">
              <template slot="append">mmol/l</template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="血脂" prop="field122">
            <el-input v-model="formData.cBloodFat" clearable :style="{width: '100%'}">
              <template slot="append">mmol/l</template>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="发病日期" prop="field124">
            <el-date-picker v-model="formData.cStartDate" format="" value-format=""
              :style="{width: '100%'}" clearable></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="主诉" prop="field128">
            <el-input v-model="formData.cAction" clearable :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="现病史" prop="field129">
            <el-input v-model="formData.cNewCase" type="textarea" placeholder="请输入现病史"
              :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="既往史" prop="field130">
            <el-input v-model="formData.cBeforeCase" type="textarea" placeholder="请输入既往史"
              :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="过敏史" prop="field131">
            <el-input v-model="formData.cAllergy" type="textarea" :autosize="{minRows: 4, maxRows: 4}"
              :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="个人史" prop="field132">
            <el-input v-model="formData.cPersonal" type="textarea" :autosize="{minRows: 4, maxRows: 4}"
              :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="家族史" prop="field133">
            <el-input v-model="formData.cFamily" type="textarea" :autosize="{minRows: 4, maxRows: 4}"
              :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="辅助检查" prop="field134">
            <el-input v-model="formData.cAuxiliary" type="textarea" :autosize="{minRows: 4, maxRows: 4}"
              :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="治疗意见" prop="field135">
            <el-input v-model="formData.cOpinion" type="textarea" placeholder="请输入治疗意见"
              :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="备注" prop="field136">
            <el-input v-model="formData.cNotes" type="textarea" placeholder="请输入备注"
              :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item size="large">
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
    </div>

  </div>
</template>

<script>
import { listPatient, getPatient, delPatient, addPatient, updatePatient } from "@/api/patientsystem/patient";
import { listCases, getCases, delCases, addCases, updateCases } from "@/api/drugs/cases";
export default {
  components: {},
  props: [],
  data() {
    return {
      form:{
        pName: null,
        pNo: null,
        pAge: null,
        pStartDate: null,
        pSex: null,
        pPhone: null,
        pCard: null,
        pProvince: null,
        pPlace: null,
        pArea: null,

      },
     formData:{
      pId:'',
      cDiagnose:null,
      cAdvice:null,
      cTemperature:null,
      cBreathe:null,
      cPulse:null,
      cBloodPressure:null,
      cHeight:null,
      cWeight:null,
      cBloodSugar:null,
      cBloodFat:null,
      cStartDate:null,
      cAction:null,
      cNewCase:null,
      cBeforeCase:null,
      cAllergy:null,
      cPersonal:null,
      cFamily:null,
      cAuxiliary:null,
      cOpinion:null,
      cNotes:null,
     }

    }
  },
  computed: {},
  watch: {},
  mounted() {},
  methods: {
    submitForm() {
      this.formData.pId=this.form.id;
     addCases(this.formData).then(response =>{
      this.$modal.msgSuccess("新增成功");
     })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
    queryById(){
      let id  = this.$route.query.id
      if(id!=null){
        getPatient(id).then(response => {
          this.form = response.data;
          console.log(this.form);
          this.open = true;
        });
      }
    },

  },
  created(){
    this.queryById();
  }
}

</script>
<style>
</style>
